package leetcode.treeCode.week5.leetcode_108;

class Solution {
    public TreeNode sortedArrayToBST(int[] nums) {
        TreeNode node = build(nums, 0, nums.length - 1);
        return node;
    }

    private TreeNode build(int[] nums, int left, int right) {
        int index = left + (right - left) / 2;
        TreeNode node = new TreeNode(nums[index]);
        node.left = build(nums, left, index - 1);
        node.right = build(nums, index +1 , right);
        return node;
    }
}